import shutil, os, sys
from pathlib import Path
import datetime
import updateModelParamsUtils, MyUtils


def demo(rootPath,srcProductPath="product1/model", dstModelPathList=['product1/model', 'product2/model'],commitInfo="xxx"):
    #rootPath = 'E:/workspace/0_model/0_shenzhenHuaxing_piantie-new/'
     modelName = srcProductPath.split('/')[-1]
     srcModelPath = srcProductPath
     if( not os.path.exists(srcModelPath)):
            print("srcModelPath path not exist: ", srcModelPath)
            exit(0)
     else:
         print(">>> src model: ", srcModelPath)
         print(">>>")

     dstModelPathList = dstModelPathList
    
     stepIdxListNot = [0]

     publish = rootPath
     updateModelParamsUtils.modelUpdateDemo(commitInfo, srcModelPath,dstModelPathList,stepIdxListNot,publish)
     if publish is None:
          print("未批量发布model")


def moduleSL_duanzi():
    exit(0)
    rootPath = 'E:\\workspace\\0_model\\夏普\\SL\\SL端子\\反面/'
    dstProductsList=["反12.2","反16.3"]

    #编辑参数####################################################
    srcProduct="反12.2"
    commitInfo = "更新model，采用梯度差分检测"
    #编辑参数####################################################


    print("commitInfo: ", commitInfo)
    inputStr = input("当前源model："+srcProduct+"\n是否确认更新(y/n): ")
    print(inputStr)
    if inputStr != 'y':
        print("指令错误: " + inputStr)
        exit(0)

    commitInfo = commitInfo+", 同步model-"+srcProduct

    dstModelPathList = []
    for dstProducts in dstProductsList:
        dstModelPathList.append(rootPath+dstProducts+"/model-sl-electrode-check-"+dstProducts+"/")
    

    srcProductPath=rootPath+srcProduct+"/model-sl-electrode-check-"+srcProduct+"/"
    demo(rootPath=None,srcProductPath=srcProductPath, 
        dstModelPathList=dstModelPathList,commitInfo=commitInfo)
    

if __name__ == "__main__":  
    currentTime = datetime.datetime.now().strftime('%Y-%m-%d  %H:%M:%S')
    currentDate = datetime.datetime.now().strftime('%Y-%m-%d')

    moduleSL_duanzi()

    exit(0)


    
